#include <SDL/SDL.h>
#include <vector>

#include "mouse.h"
#include "keyboard.h"
#include "inputdevices.h"

#include "game.h"

InputDevices::InputDevices():kbd(),mouse()
{
}

InputDevices::~InputDevices()
{
}

void InputDevices::update()
{
	//Primero actualizamos los old_event de los perifericos
	kbd.update();
	//mouse.update();

	SDL_Event event;
	while(SDL_PollEvent(&event))
	{
		switch(event.type)
		{
			//Quit event
			case SDL_QUIT:
				Game::self().setEnd();
				break;

			//Keyboard's events
			case SDL_KEYDOWN:
			case SDL_KEYUP:
				kbd.receiveEvent(event);
				break;

        /*
			//Mouse's events
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEBUTTONUP:
			case SDL_MOUSEMOTION:
				mouse.receiveEvent(event);
				break;
        */
				
			default:
				break;
		}
	}
}

bool InputDevices::isEventTriggered(const Event& event,Sint32& magnitude)
{
  switch(event.peripheral)
  {
    case Event::KEYBOARD:
      return kbd.isEventTriggered(event,magnitude);
      break;
      /*
    case Event::MOUSE:
      return mouse.isEventTriggered(event,magnitude);
      break;
      */
    default:
      break;
  }
  return false;
}
